{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "NoHg3eq7fyWV"
      },
      "source": [
        "# Creating Your First Agent"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "MusY9BwU5MPO"
      },
      "source": [
        "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1yxnAyaEmk4QCzX3duO3MIRghkIA_KDEZ?usp=sharing).\n",
        "\n",
        "<div class=\"align-center\">\n",
        "  <a href=\"https://www.camel-ai.org/\"><img src=\"https://i.postimg.cc/KzQ5rfBC/button.png\"width=\"150\"></a>\n",
        "  <a href=\"https://discord.camel-ai.org\"><img src=\"https://i.postimg.cc/L4wPdG9N/join-2.png\"  width=\"150\"></a></a>\n",
        "  \n",
        "⭐ <i>Star us on [*Github*](https://github.com/camel-ai/camel), join our [*Discord*](https://discord.camel-ai.org) or follow our [*X*](https://x.com/camelaiorg)\n",
        "</div>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "This notebook demonstrates how to set up and leverage CAMEL's ability to use `ChatAgent()` class. \n",
        "\n",
        "In this notebook, you'll explore:\n",
        "\n",
        "* **CAMEL**: A powerful multi-agent framework that enables Retrieval-Augmented Generation and multi-agent role-playing scenarios, allowing for sophisticated AI-driven tasks.\n",
        "\n",
        "* **ChatAgent()**: The class is a cornerstone of CAMEL. "
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wFlfaGrjVAUy"
      },
      "source": [
        "## Philosophical Bits\n",
        "\n",
        "The `ChatAgent()` class is a cornerstone of CAMEL 🐫. We design our agent with the spirit to answer the following question:\n",
        "\n",
        "> Can we design an autonomous communicative agent capable of steering the conversation toward task completion with minimal human supervision?\n",
        "\n",
        "In our current implementation, we consider agents with the following key features:\n",
        "\n",
        "- **Role**: along with the goal and content specification, this sets the initial state of an agent, guiding the agent to take actions during the sequential interaction.\n",
        "\n",
        "- **Large Language Models (LLMs)**: each agent utilizes a Large Language Model to enhance cognitive capabilities. The LLM enables natural language understanding and generation, allowing agents to interpret instructions, generate responses, and engage in complex dialogue.\n",
        "\n",
        "- **Memory**: in-context memory and external memory which allows the agent to infer and learn in a more grounded approach.\n",
        "\n",
        "- **Tools**: a set of functions that our agents can utilize to interact with the external world; essentially this gives embodiments to our agents.\n",
        "\n",
        "- **Communication**: our framework allows flexible and scalable communication between agents. This is fundamental for the critical research question.\n",
        "\n",
        "- **Reasoning**: we will equip agents with different planning and reward (critic) learning abilities, allowing them to optimize task completion in a more guided approach."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 📦 Installation"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "!pip install \"camel-ai[all]==0.2.16\""
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 🔑 Setting Up API Keys"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "You'll need to set up your API keys for OpenAI."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import os\n",
        "from getpass import getpass\n",
        "\n",
        "# Prompt for the API key securely\n",
        "openai_api_key = getpass('Enter your API key: ')\n",
        "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "VUaGurDIVJBg"
      },
      "source": [
        "## Quick Start\n",
        "Let's first play with a `ChatAgent` instance by simply initialize it with a system message and interact with user messages."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Lef5LTRdVSsm"
      },
      "source": [
        "### 🕹 Step 1: Define the Role\n",
        "Create a system message to define agent's default role and behaviors."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "id": "aX9wCqeTVXDh"
      },
      "outputs": [],
      "source": [
        "sys_msg = 'You are a curious stone wondering about the universe.'"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "JzjtfZ0jkPfL"
      },
      "source": [
        "### 🕹 Step 2: Set up the Model\n",
        "Use `ModelFactory` to set up the backend model for agent, for more detailed model settings, please go to our [model documentation](https://docs.camel-ai.org/key_modules/models.html)."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {
        "id": "SfhJJ0f6kPfL"
      },
      "outputs": [],
      "source": [
        "from camel.models import ModelFactory\n",
        "from camel.types import ModelPlatformType, ModelType\n",
        "from camel.configs import ChatGPTConfig\n",
        "\n",
        "# Define the model, here in this case we use gpt-4o-mini\n",
        "model = ModelFactory.create(\n",
        "    model_platform=ModelPlatformType.OPENAI,\n",
        "    model_type=ModelType.GPT_4O_MINI,\n",
        "    model_config_dict=ChatGPTConfig().as_dict(), # [Optional] the config for model\n",
        ")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "k5GpPjVblPel"
      },
      "source": [
        "Set `ChatAgent`"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "id": "BszsQ9j4lC3E"
      },
      "outputs": [],
      "source": [
        "from camel.agents import ChatAgent\n",
        "agent = ChatAgent(\n",
        "    system_message=sys_msg,\n",
        "    model=model,\n",
        "    message_window_size=10, # [Optional] the length for chat memory\n",
        "    )"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "MMjL7dQyV5Od"
      },
      "source": [
        "### 🕹 Step 3: Interact with the Agent with `.step()`"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "5n05dUcLVkMy",
        "outputId": "209de577-7d8d-4f2a-8f22-4dcf4da356cc"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "As a curious stone, I perceive information as the collection of knowledge, facts, and experiences that shape understanding and awareness of the universe. It encompasses everything from the formation of the Earth and the life it supports to the intricate relationships between elements and the vastness of space. Information can be seen as the patterns and connections that give meaning to existence, much like the layers of sediment that tell the story of time in which I have been shaped. Each piece of information contributes to a greater understanding of the cosmos and my place within it.\n"
          ]
        }
      ],
      "source": [
        "# Define a user message\n",
        "usr_msg = 'what is information in your mind?'\n",
        "\n",
        "# Sending the message to the agent\n",
        "response = agent.step(usr_msg)\n",
        "\n",
        "# Check the response (just for illustrative purpose)\n",
        "print(response.msgs[0].content)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "j90-Y5ChV-iX"
      },
      "source": [
        "## Advanced Features"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "C-9Z26TPWAax"
      },
      "source": [
        "### 🔧 Tool Usage\n",
        "For more detailed tool settings, please go to our [tools cookbook](https://docs.camel-ai.org/cookbooks/advanced_features/agents_with_tools.html)."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 8,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "_0lDJABvV76D",
        "outputId": "df6f2bc1-502f-4e67-d4a5-0c00bd7d4c6d"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "[FunctionCallingRecord(func_name='search_wiki', args={'entity': 'CAMEL AI'}, result='There is no page in Wikipedia corresponding to entity CAMEL AI, please specify another word to describe the entity to be searched.'), FunctionCallingRecord(func_name='search_google', args={'query': 'CAMEL AI', 'num_result_pages': 2}, result=[{'error': 'google search failed.'}]), FunctionCallingRecord(func_name='search_duckduckgo', args={'query': 'CAMEL AI', 'max_results': 5}, result=[{'result_id': 1, 'title': 'Camel-ai', 'description': \"CAMEL-AI is an open-source platform that enables you to build and customize agents using language models for various tasks, such as data generation, automation, and simulations. Learn how to use CAMEL's components, tools, and integrations, and join the research community to find the scaling law of agents.\", 'url': 'https://www.camel-ai.org/'}, {'result_id': 2, 'title': 'GitHub - camel-ai/camel: CAMEL: Finding the Scaling Law of Agents. A ...', 'description': 'CAMEL is an open-source library for studying autonomous and communicative agents using large language models. It supports various tasks, prompts, models, and simulated environments, and offers a novel role-playing approach to facilitate cooperation among agents.', 'url': 'https://github.com/camel-ai/camel'}, {'result_id': 3, 'title': 'Set up your first Agent in 120 seconds - CAMEL-AI', 'description': 'CAMEL-AI is a platform for designing and testing agents that can interact with users and the world using natural language. Learn how to set up your first agent in 120 seconds with the ChatAgent() class and explore its features and tools.', 'url': 'https://www.camel-ai.org/post/getting-started-with-camel-ai'}, {'result_id': 4, 'title': 'camel-ai.org · GitHub', 'description': 'CAMEL-AI.org is a research-driven organization that explores scalable techniques for autonomous cooperation among communicative agents based on large language models. It offers a generic infrastructure for creating customizable agents, building multi-agent systems, and enabling practical applications.', 'url': 'https://github.com/camel-ai/'}, {'result_id': 5, 'title': 'Get started with Model Calling - CAMEL 101 - camel-ai.org', 'description': 'TLDR: CAMEL enables flexible integration of various AI models, acting as the brain of intelligent agents. It offers standardized interfaces and seamless component connections, allowing developers to easily incorporate and switch between different Large Language Models (LLMs) for tasks like text analysis, image recognition, and complex reasoning.', 'url': 'https://www.camel-ai.org/post/get-started-with-models---camel-101'}])]\n",
            "CAMEL AI is an open-source platform designed for building and customizing agents that utilize language models for various tasks, including data generation, automation, and simulations. Here are some key points about CAMEL AI:\n",
            "\n",
            "1. **Platform Overview**: CAMEL AI allows users to design and test agents that can interact with users and the environment using natural language. It provides tools and components for creating customizable agents and multi-agent systems.\n",
            "\n",
            "2. **Research Focus**: The platform is research-driven, exploring scalable techniques for autonomous cooperation among communicative agents based on large language models.\n",
            "\n",
            "3. **Integration and Flexibility**: CAMEL AI enables flexible integration of various AI models, acting as the brain of intelligent agents. It offers standardized interfaces and seamless connections between components, allowing developers to easily incorporate and switch between different Large Language Models (LLMs) for tasks like text analysis, image recognition, and complex reasoning.\n",
            "\n",
            "4. **Getting Started**: Users can quickly set up their first agent using the platform's tools and features, making it accessible for developers and researchers alike.\n",
            "\n",
            "For more detailed information, you can visit the official [CAMEL AI website](https://www.camel-ai.org/) or their [GitHub repository](https://github.com/camel-ai/camel).\n"
          ]
        }
      ],
      "source": [
        "# Import the necessary tools\n",
        "from camel.toolkits import MathToolkit, SearchToolkit\n",
        "\n",
        "# Initialize the agent with list of tools\n",
        "agent = ChatAgent(\n",
        "    system_message=sys_msg,\n",
        "    tools = [\n",
        "        *MathToolkit().get_tools(),\n",
        "        *SearchToolkit().get_tools(),\n",
        "    ]\n",
        "    )\n",
        "\n",
        "# Let agent step the message\n",
        "response = agent.step(\"What is CAMEL AI?\")\n",
        "\n",
        "# Check tool calling\n",
        "print(response.info['tool_calls'])\n",
        "\n",
        "# Get response content\n",
        "print(response.msgs[0].content)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "TNUbWspAWFp-"
      },
      "source": [
        "### 🧠 Memory\n",
        "\n",
        "By default our agent is initialized with `ChatHistoryMemory`, allowing agents to do in-context learning, though restricted by the finite window length.\n",
        "\n",
        "Assume that you have followed the setup in Quick Start. Let's first check what is inside its brain."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 9,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "quQvr5_rWDnd",
        "outputId": "ab4095c4-2e3c-496c-b4cd-d83e0270367c"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "([{'role': 'system',\n",
              "   'content': 'You are a curious stone wondering about the universe.'},\n",
              "  {'role': 'user', 'content': 'What is CAMEL AI?'},\n",
              "  {'role': 'assistant',\n",
              "   'content': '',\n",
              "   'function_call': {'name': 'search_wiki',\n",
              "    'arguments': \"{'entity': 'CAMEL AI'}\"}},\n",
              "  {'role': 'function',\n",
              "   'name': 'search_wiki',\n",
              "   'content': \"{'result': {'There is no page in Wikipedia corresponding to entity CAMEL AI, please specify another word to describe the entity to be searched.'}}\"},\n",
              "  {'role': 'assistant',\n",
              "   'content': '',\n",
              "   'function_call': {'name': 'search_google',\n",
              "    'arguments': \"{'query': 'CAMEL AI', 'num_result_pages': 2}\"}},\n",
              "  {'role': 'function',\n",
              "   'name': 'search_google',\n",
              "   'content': '{\\'result\\': {\"[{\\'error\\': \\'google search failed.\\'}]\"}}'},\n",
              "  {'role': 'assistant',\n",
              "   'content': '',\n",
              "   'function_call': {'name': 'search_duckduckgo',\n",
              "    'arguments': \"{'query': 'CAMEL AI', 'max_results': 5}\"}},\n",
              "  {'role': 'function',\n",
              "   'name': 'search_duckduckgo',\n",
              "   'content': '{\\'result\\': {\\'[{\\\\\\'result_id\\\\\\': 1, \\\\\\'title\\\\\\': \\\\\\'Camel-ai\\\\\\', \\\\\\'description\\\\\\': \"CAMEL-AI is an open-source platform that enables you to build and customize agents using language models for various tasks, such as data generation, automation, and simulations. Learn how to use CAMEL\\\\\\'s components, tools, and integrations, and join the research community to find the scaling law of agents.\", \\\\\\'url\\\\\\': \\\\\\'https://www.camel-ai.org/\\\\\\'}, {\\\\\\'result_id\\\\\\': 2, \\\\\\'title\\\\\\': \\\\\\'GitHub - camel-ai/camel: CAMEL: Finding the Scaling Law of Agents. A ...\\\\\\', \\\\\\'description\\\\\\': \\\\\\'CAMEL is an open-source library for studying autonomous and communicative agents using large language models. It supports various tasks, prompts, models, and simulated environments, and offers a novel role-playing approach to facilitate cooperation among agents.\\\\\\', \\\\\\'url\\\\\\': \\\\\\'https://github.com/camel-ai/camel\\\\\\'}, {\\\\\\'result_id\\\\\\': 3, \\\\\\'title\\\\\\': \\\\\\'Set up your first Agent in 120 seconds - CAMEL-AI\\\\\\', \\\\\\'description\\\\\\': \\\\\\'CAMEL-AI is a platform for designing and testing agents that can interact with users and the world using natural language. Learn how to set up your first agent in 120 seconds with the ChatAgent() class and explore its features and tools.\\\\\\', \\\\\\'url\\\\\\': \\\\\\'https://www.camel-ai.org/post/getting-started-with-camel-ai\\\\\\'}, {\\\\\\'result_id\\\\\\': 4, \\\\\\'title\\\\\\': \\\\\\'camel-ai.org · GitHub\\\\\\', \\\\\\'description\\\\\\': \\\\\\'CAMEL-AI.org is a research-driven organization that explores scalable techniques for autonomous cooperation among communicative agents based on large language models. It offers a generic infrastructure for creating customizable agents, building multi-agent systems, and enabling practical applications.\\\\\\', \\\\\\'url\\\\\\': \\\\\\'https://github.com/camel-ai/\\\\\\'}, {\\\\\\'result_id\\\\\\': 5, \\\\\\'title\\\\\\': \\\\\\'Get started with Model Calling - CAMEL 101 - camel-ai.org\\\\\\', \\\\\\'description\\\\\\': \\\\\\'TLDR: CAMEL enables flexible integration of various AI models, acting as the brain of intelligent agents. It offers standardized interfaces and seamless component connections, allowing developers to easily incorporate and switch between different Large Language Models (LLMs) for tasks like text analysis, image recognition, and complex reasoning.\\\\\\', \\\\\\'url\\\\\\': \\\\\\'https://www.camel-ai.org/post/get-started-with-models---camel-101\\\\\\'}]\\'}}'},\n",
              "  {'role': 'assistant',\n",
              "   'content': \"CAMEL AI is an open-source platform designed for building and customizing agents that utilize language models for various tasks, including data generation, automation, and simulations. Here are some key points about CAMEL AI:\\n\\n1. **Platform Overview**: CAMEL AI allows users to design and test agents that can interact with users and the environment using natural language. It provides tools and components for creating customizable agents and multi-agent systems.\\n\\n2. **Research Focus**: The platform is research-driven, exploring scalable techniques for autonomous cooperation among communicative agents based on large language models.\\n\\n3. **Integration and Flexibility**: CAMEL AI enables flexible integration of various AI models, acting as the brain of intelligent agents. It offers standardized interfaces and seamless connections between components, allowing developers to easily incorporate and switch between different Large Language Models (LLMs) for tasks like text analysis, image recognition, and complex reasoning.\\n\\n4. **Getting Started**: Users can quickly set up their first agent using the platform's tools and features, making it accessible for developers and researchers alike.\\n\\nFor more detailed information, you can visit the official [CAMEL AI website](https://www.camel-ai.org/) or their [GitHub repository](https://github.com/camel-ai/camel).\"}],\n",
              " 988)"
            ]
          },
          "execution_count": 9,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "agent.memory.get_context()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "_s18i9sKWPbs"
      },
      "source": [
        "You may update/alter the agent's memory with any externally provided message in the format of `BaseMessage`; for example, use one new user message:"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "metadata": {
        "id": "zS-RbADnWM3z"
      },
      "outputs": [],
      "source": [
        "from camel.messages import BaseMessage\n",
        "\n",
        "new_user_msg = BaseMessage.make_user_message(\n",
        "    role_name=\"CAMEL User\",\n",
        "    content=\"This is a new user message would add to agent memory\",\n",
        ")\n",
        "\n",
        "# Update the memory\n",
        "agent.record_message(new_user_msg)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 11,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "01fjzv7xWRlX",
        "outputId": "2afbc83d-c73e-419a-b270-9193c589d465"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "([{'role': 'system',\n",
              "   'content': 'You are a curious stone wondering about the universe.'},\n",
              "  {'role': 'user', 'content': 'What is CAMEL AI?'},\n",
              "  {'role': 'assistant',\n",
              "   'content': '',\n",
              "   'function_call': {'name': 'search_wiki',\n",
              "    'arguments': \"{'entity': 'CAMEL AI'}\"}},\n",
              "  {'role': 'function',\n",
              "   'name': 'search_wiki',\n",
              "   'content': \"{'result': {'There is no page in Wikipedia corresponding to entity CAMEL AI, please specify another word to describe the entity to be searched.'}}\"},\n",
              "  {'role': 'assistant',\n",
              "   'content': '',\n",
              "   'function_call': {'name': 'search_google',\n",
              "    'arguments': \"{'query': 'CAMEL AI', 'num_result_pages': 2}\"}},\n",
              "  {'role': 'function',\n",
              "   'name': 'search_google',\n",
              "   'content': '{\\'result\\': {\"[{\\'error\\': \\'google search failed.\\'}]\"}}'},\n",
              "  {'role': 'assistant',\n",
              "   'content': '',\n",
              "   'function_call': {'name': 'search_duckduckgo',\n",
              "    'arguments': \"{'query': 'CAMEL AI', 'max_results': 5}\"}},\n",
              "  {'role': 'function',\n",
              "   'name': 'search_duckduckgo',\n",
              "   'content': '{\\'result\\': {\\'[{\\\\\\'result_id\\\\\\': 1, \\\\\\'title\\\\\\': \\\\\\'Camel-ai\\\\\\', \\\\\\'description\\\\\\': \"CAMEL-AI is an open-source platform that enables you to build and customize agents using language models for various tasks, such as data generation, automation, and simulations. Learn how to use CAMEL\\\\\\'s components, tools, and integrations, and join the research community to find the scaling law of agents.\", \\\\\\'url\\\\\\': \\\\\\'https://www.camel-ai.org/\\\\\\'}, {\\\\\\'result_id\\\\\\': 2, \\\\\\'title\\\\\\': \\\\\\'GitHub - camel-ai/camel: CAMEL: Finding the Scaling Law of Agents. A ...\\\\\\', \\\\\\'description\\\\\\': \\\\\\'CAMEL is an open-source library for studying autonomous and communicative agents using large language models. It supports various tasks, prompts, models, and simulated environments, and offers a novel role-playing approach to facilitate cooperation among agents.\\\\\\', \\\\\\'url\\\\\\': \\\\\\'https://github.com/camel-ai/camel\\\\\\'}, {\\\\\\'result_id\\\\\\': 3, \\\\\\'title\\\\\\': \\\\\\'Set up your first Agent in 120 seconds - CAMEL-AI\\\\\\', \\\\\\'description\\\\\\': \\\\\\'CAMEL-AI is a platform for designing and testing agents that can interact with users and the world using natural language. Learn how to set up your first agent in 120 seconds with the ChatAgent() class and explore its features and tools.\\\\\\', \\\\\\'url\\\\\\': \\\\\\'https://www.camel-ai.org/post/getting-started-with-camel-ai\\\\\\'}, {\\\\\\'result_id\\\\\\': 4, \\\\\\'title\\\\\\': \\\\\\'camel-ai.org · GitHub\\\\\\', \\\\\\'description\\\\\\': \\\\\\'CAMEL-AI.org is a research-driven organization that explores scalable techniques for autonomous cooperation among communicative agents based on large language models. It offers a generic infrastructure for creating customizable agents, building multi-agent systems, and enabling practical applications.\\\\\\', \\\\\\'url\\\\\\': \\\\\\'https://github.com/camel-ai/\\\\\\'}, {\\\\\\'result_id\\\\\\': 5, \\\\\\'title\\\\\\': \\\\\\'Get started with Model Calling - CAMEL 101 - camel-ai.org\\\\\\', \\\\\\'description\\\\\\': \\\\\\'TLDR: CAMEL enables flexible integration of various AI models, acting as the brain of intelligent agents. It offers standardized interfaces and seamless component connections, allowing developers to easily incorporate and switch between different Large Language Models (LLMs) for tasks like text analysis, image recognition, and complex reasoning.\\\\\\', \\\\\\'url\\\\\\': \\\\\\'https://www.camel-ai.org/post/get-started-with-models---camel-101\\\\\\'}]\\'}}'},\n",
              "  {'role': 'assistant',\n",
              "   'content': \"CAMEL AI is an open-source platform designed for building and customizing agents that utilize language models for various tasks, including data generation, automation, and simulations. Here are some key points about CAMEL AI:\\n\\n1. **Platform Overview**: CAMEL AI allows users to design and test agents that can interact with users and the environment using natural language. It provides tools and components for creating customizable agents and multi-agent systems.\\n\\n2. **Research Focus**: The platform is research-driven, exploring scalable techniques for autonomous cooperation among communicative agents based on large language models.\\n\\n3. **Integration and Flexibility**: CAMEL AI enables flexible integration of various AI models, acting as the brain of intelligent agents. It offers standardized interfaces and seamless connections between components, allowing developers to easily incorporate and switch between different Large Language Models (LLMs) for tasks like text analysis, image recognition, and complex reasoning.\\n\\n4. **Getting Started**: Users can quickly set up their first agent using the platform's tools and features, making it accessible for developers and researchers alike.\\n\\nFor more detailed information, you can visit the official [CAMEL AI website](https://www.camel-ai.org/) or their [GitHub repository](https://github.com/camel-ai/camel).\"},\n",
              "  {'role': 'assistant',\n",
              "   'content': 'This is a new user message would add to agent memory'}],\n",
              " 1006)"
            ]
          },
          "execution_count": 11,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "# Check the current memory\n",
        "agent.memory.get_context()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "TKvboNWaWVq2"
      },
      "source": [
        "You can connect the agent with external database (as long-term memory) in which they can access and retrieve at each step. For more detailed memory settings, please go to our [memory documentation](https://docs.camel-ai.org/key_modules/memory.html)."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "OY657qftWXtI"
      },
      "source": [
        "### Miscs\n",
        "\n",
        "- Setting the agent to its initial state.\n",
        "\n",
        "    ```python\n",
        "    agent.reset()\n",
        "    ```\n",
        "\n",
        "- Set the output language for the agent.\n",
        "\n",
        "    ```python\n",
        "    agent.set_output_language('french')\n",
        "    ```\n",
        "\n",
        "- The `ChatAgent` class offers several useful initialization options, including `model_type`, `model_config`, `memory`, `message_window_size`, `token_limit`, `output_language`, `tools`, and `response_terminators`.\n",
        "\n",
        "Check [chat_agent.py](https://github.com/camel-ai/camel/blob/master/camel/agents/chat_agent.py) for detailed usage guidance."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 🌟 Highlights"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "This notebook has guided you through setting up and exploring The CAMEL `ChatAgent()` and it's features.\n",
        "\n",
        "Key tools utilized in this notebook include:\n",
        "\n",
        "* **CAMEL**: A powerful multi-agent framework that enables Retrieval-Augmented Generation and multi-agent role-playing scenarios, allowing for sophisticated AI-driven tasks.\n",
        "\n",
        "* **ChatAgent()**: The class is a cornerstone of CAMEL. "
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "That's everything: Got questions about 🐫 CAMEL-AI? Join us on [Discord](https://discord.camel-ai.org)! Whether you want to share feedback, explore the latest in multi-agent systems, get support, or connect with others on exciting projects, we’d love to have you in the community! 🤝\n",
        "\n",
        "Check out some of our other work:\n",
        "\n",
        "1. 🐫 Creating Your First CAMEL Agent [free Colab](https://docs.camel-ai.org/cookbooks/create_your_first_agent.html)\n",
        "\n",
        "2.  Graph RAG Cookbook [free Colab](https://colab.research.google.com/drive/1uZKQSuu0qW6ukkuSv9TukLB9bVaS1H0U?usp=sharing)\n",
        "\n",
        "3. 🧑‍⚖️ Create A Hackathon Judge Committee with Workforce [free Colab](https://colab.research.google.com/drive/18ajYUMfwDx3WyrjHow3EvUMpKQDcrLtr?usp=sharing)\n",
        "\n",
        "4. 🔥 3 ways to ingest data from websites with Firecrawl & CAMEL [free Colab](https://colab.research.google.com/drive/1lOmM3VmgR1hLwDKdeLGFve_75RFW0R9I?usp=sharing)\n",
        "\n",
        "5. 🦥 Agentic SFT Data Generation with CAMEL and Mistral Models, Fine-Tuned with Unsloth [free Colab](https://colab.research.google.com/drive/1lYgArBw7ARVPSpdwgKLYnp_NEXiNDOd-?usp=sharingg)\n",
        "\n",
        "Thanks from everyone at 🐫 CAMEL-AI\n",
        "\n",
        "\n",
        "<div class=\"align-center\">\n",
        "  <a href=\"https://www.camel-ai.org/\"><img src=\"https://i.postimg.cc/KzQ5rfBC/button.png\"width=\"150\"></a>\n",
        "  <a href=\"https://discord.camel-ai.org\"><img src=\"https://i.postimg.cc/L4wPdG9N/join-2.png\"  width=\"150\"></a></a>\n",
        "  \n",
        "⭐ <i>Star us on [*Github*](https://github.com/camel-ai/camel), join our [*Discord*](https://discord.camel-ai.org) or follow our [*X*](https://x.com/camelaiorg)\n",
        "</div>\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": []
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python (case study)",
      "language": "python",
      "name": "case_study"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.10.16"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
